<template>
    <div class="container">
        <!-- 数据大屏展示内容区域 -->
        <div class="screen" ref="screen">
            <div class="top">
                <TopScreen />
            </div>
            <div class="bottom">
                <div class="left">
                    <Tourist class="tourist" />
                    <Sex class="sex" />
                    <Age class="age" />
                </div>
                <div class="center">
                    <Map class="map"></Map>
                    <Line class="line" />
                </div>
                <div class="right">
                    <rank class="rank" />
                    <Year class="year" />
                    <Couter class="couter" />
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang='ts' name='SCREEN'>
let screen = ref();

// 大屏缩放比例
function zoomScreen(w = 1920, h = 1080): number {
    const ww = window.innerWidth;
    const wh = window.innerHeight;
    return Math.min(ww / w, wh / h);
}

function resizeScreen() {
    screen.value.style.transform = `scale(${zoomScreen()}) translate(-50%, -50%)`;
}

// 监听屏幕大小变化
window.onresize = () => {
    console.log('resize');
    resizeScreen();
};

onMounted(() => {
    resizeScreen();
});
</script>

<style scoped lang='scss'>
.container {
    width: 100vw;
    height: 100vh;
    background: url(./images/bg.png) no-repeat;
    background-size: cover;

    .screen {
        position: fixed;
        width: 1920px;
        height: 1080px;
        left: 50%;
        top: 50%;
        transform-origin: left top;

        .top {
            width: 100%;
            height: 40px;
        }

        .bottom {
            display: flex;
            margin: 0px 20px;

            .left {
                flex: 1;
                height: 1040px;
                display: flex;
                flex-direction: column;

                .tourist {
                    flex: 1.5;
                }

                .sex {
                    flex: 1;
                }

                .age {
                    flex: 1;
                }
            }

            .right {
                flex: 1;
                height: 1040px;
                display: flex;
                flex-direction: column;

                .rank {
                    flex: 1.5;
                }

                .year {
                    flex: 1;
                }

                .couter {
                    flex: 1;
                }
            }

            .center {
                flex: 2;
                display: flex;
                flex-direction: column;
                margin: 0px 10px 10px 10px;

                .map {
                    flex: 4;
                }

                .line {
                    flex: 1;
                }

            }
        }
    }
}
</style>